////////////////////////////////////////////////////////////////////////////////
//
// Code::Blocks new project wizard script
//
// Project: Console application
// Author:  Yiannis Mandravellos
//
// Wizard scripts documentation can be found at:
// http://wiki.codeblocks.org/index.php?title=Wizard_scripts
//
////////////////////////////////////////////////////////////////////////////////

multi_thread_dynamic <- true; //Default to Multi-thread. For MSVC only.
ConsoleLang <- 1; // default to C++
WizardType  <- 0; // 0 - Project, 1 - Target

//
//------------------------------------------------------------------------------
//
function BeginWizard()
{
    local wiz_type = Wizard.GetWizardType();

    if (wiz_type == wizProject)
    {
        // this is the text that will appear in the start (intro) page
        local intro_msg = _T("Welcome to the new console application wizard!\n" +
                            "This wizard will guide you to create a new console application.\n\n" +
                            "When you 're ready to proceed, please click \"Next\"...");

        // intro
        Wizard.AddInfoPage(_T("ConsoleIntro"), intro_msg);
        // select language
        Wizard.AddGenericSingleChoiceListPage(_T("ConsoleLanguagePage"), _T("Please select the language you want to use."), _T("C;C++"), ConsoleLang); // select language
        // select project name and path
        Wizard.AddProjectPathPage();
        // select compiler and configurations
        Wizard.AddCompilerPage(_T(""), _T("*"), true, true);
    }
    else if (wiz_type == wizTarget)
    {
        WizardType = 1;
        local intro_msg = _T("Welcome to the new console build target wizard!\n" +
                            "This wizard will guide you to create a new console build target.\n\n" +
                            "When you 're ready to proceed, please click \"Next\"...");
        Wizard.AddInfoPage(_T("ConsoleIntro"), intro_msg);
        Wizard.AddBuildTargetPage(_T(""), false, true, _T(""), _T("*"), true);
    }
}

//------------------------------------------------------------------------------
// Function OnEnter_ConsoleLanguagePage
//------------------------------------------------------------------------------
function OnEnter_ConsoleLanguagePage(fwd)
{
    Wizard.SetListboxSelection(_T("GenericChoiceList"), ConsoleLang);
    return true;
}
//------------------------------------------------------------------------------
// Function OnLeave_ConsoleLanguagePage
//------------------------------------------------------------------------------
function OnLeave_ConsoleLanguagePage(fwd)
{
    if (fwd)
    {
        ConsoleLang = Wizard.GetListboxSelection(_T("GenericChoiceList"));
    }
    return true;
}

//
//------------------------------------------------------------------------------
//
function OnLeave_CompilerPage(fwd)
{
    if (fwd)
    {
        if (GetCompilerFactory().CompilerInheritsFrom(Wizard.GetCompilerID(), _T("msvctk"))
         || GetCompilerFactory().CompilerInheritsFrom(Wizard.GetCompilerID(), _T("msvc8"))
         || GetCompilerFactory().CompilerInheritsFrom(Wizard.GetCompilerID(), _T("msvc10")))
        {
            local msg = _T("Wizard will setup the Project in Multi-threaded Dynamic CRT mode by default.\n\n");
            msg = msg + _T("Click Yes to continue with Multi-threaded Dynamic CRT mode\n\n");
            msg = msg + _T("Click No to continue with Multi-threaded Static CRT mode");
            local thread = Message(msg, _T("Console Wizard"), wxICON_QUESTION | wxYES_NO);
            if (thread == wxID_YES)
                multi_thread_dynamic = true;
            else
                multi_thread_dynamic = false;
        }
    }
    return true;
}
//
//------------------------------------------------------------------------------
//
function GetFilesDir()
{
    local result;

    // depending on the source type setting, return the appropriate value.
    if (ConsoleLang == 0) // C source file
        result = _T("console/c");
    else // C++ source file
        result = _T("console/cpp");

    return result;
}
/
